package camel.corp.universalcopy.a;

import android.text.TextUtils;
import android.util.Base64;
import b.a.a.a.a;
import com.camel.corp.universalcopy.a.l;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;

public class l {
  public static PublicKey a(String paramString) {
    try {
      byte[] arrayOfByte = Base64.decode(paramString, 0);
      return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(arrayOfByte));
    } catch (NoSuchAlgorithmException paramString) {
      throw new RuntimeException(paramString);
    } catch (InvalidKeySpecException paramString) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("Invalid key specification: ");
      stringBuilder.append(paramString);
      paramString = stringBuilder.toString();
      a.b("IABUtil/Security", paramString);
      throw new IOException(paramString);
    } 
  }
  
  public static boolean a(String paramString1, String paramString2, String paramString3) {
    if (TextUtils.isEmpty(paramString2) || TextUtils.isEmpty(paramString1) || TextUtils.isEmpty(paramString3)) {
      a.b("IABUtil/Security", "Purchase verification failed: missing data.");
      return false;
    } 
    return a(a(paramString1), paramString2, paramString3);
  }
  
  public static boolean a(PublicKey paramPublicKey, String paramString1, String paramString2) {
    try {
      byte[] arrayOfByte = Base64.decode(paramString2, 0);
      try {
        Signature signature = Signature.getInstance("SHA1withRSA");
        signature.initVerify(paramPublicKey);
        signature.update(paramString1.getBytes());
        if (!signature.verify(arrayOfByte)) {
          a.b("IABUtil/Security", "Signature verification failed.");
          return false;
        } 
        return true;
      } catch (NoSuchAlgorithmException paramPublicKey) {
        throw new RuntimeException(paramPublicKey);
      } catch (InvalidKeyException paramPublicKey) {
        a.b("IABUtil/Security", "Invalid key specification.");
        return false;
      } catch (SignatureException paramPublicKey) {}
      a.b("IABUtil/Security", "Signature exception.");
      return false;
    } catch (IllegalArgumentException paramPublicKey) {
      a.b("IABUtil/Security", "Base64 decoding failed.");
      return false;
    } 
  }
}


/* Location:              D:\Users\alienware\AndroidStudioProjects\Lazero\sample\sampler\classes-dex2jar\com\camel.jar!\camel\cor\\universalcopy\a\l.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.0.7
 */